package com.wang.exam.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    //访问static文件下的资源
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/index");
        registry.addViewController("/index.html").setViewName("/index");
        registry.addViewController("/carouselMap").setViewName("/carouselMap");
        registry.addViewController("/admin/update_password").setViewName("/admin_up_password");
        registry.addViewController("/teacher/update_password").setViewName("/teacher_up_password");
        registry.addViewController("/student/update_password").setViewName("/student_up_password");
        registry.addViewController("/admin").setViewName("/admin");
        registry.addViewController("/test").setViewName("/test");
        registry.addViewController("/teacher_log_msg").setViewName("/teacher_log_msg");
        registry.addViewController("/student_log_msg").setViewName("/student_log_msg");
        registry.addViewController("/exam_course_msg").setViewName("/exam_course_msg");
        registry.addViewController("/student_ex_course").setViewName("/student_ex_course");
        registry.addViewController("/start_exam").setViewName("/start_exam");
        registry.addViewController("/student_grade").setViewName("/student_grade");
        registry.addViewController("/student/startExam").setViewName("/exam_856701");
        registry.addViewController("/teacher_exam_course").setViewName("/teacher_exam_course");
        registry.addViewController("/studentsGrades").setViewName("/studentsGrades");
        registry.addViewController("/majorsCourses").setViewName("/majorsCourses");
        registry.addViewController("/lookStudentsGrade").setViewName("/lookStudentsGrade");
        registry.addViewController("/setExam").setViewName("/setExam");
        registry.addViewController("/handExam").setViewName("/handExam");
        registry.addViewController("/systemExam").setViewName("/systemExam");
        registry.addViewController("/courseManager").setViewName("/questionManager");
        registry.addViewController("/examination").setViewName("/questionBankManager");
        registry.addViewController("/exam_over").setViewName("/exam_over");

    }
    //添加拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**").excludePathPatterns("/index.html","/",
                "/admin/main","/teacher/main","/student/main",
                "/static/**","/js/**","/img/**","/carouselMap","/teacherList","/studentList","/courseList",
                "/teacher/update_password","/teacher/updatePassword","/student/update_password","/student/updatePassword",
                "/student_ex_course","/studentCourseList","/student_grade","/start_exam","/student/startExam","/exam/grade","/examGrade",
                "/studentGradeLists","/teacherExamCourseLists","/teacher_exam_course","/studentsGrades","/lookStudentsGrade","/studentsGradesLists",
                "/up_student_grade","/de_student_grade","/add_major_course","/de_major_course","/up_major_course","/setExam","/setExamCourse",
                "/handExam","/systemExam","/exam/examTests","/testContent","/exam_over","/examGrade");
    }
}
